import { request } from "@/utils/service"
import type * as Eval from "./types/eval"
import { AxiosResponse } from "axios"
import { AlgoTypeEnum } from "@/constants/other-keys"

/** 增 */
export function createEvalDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/eval_model/add",
    method: "post",
    data
  })
}

/** 删 */
export function deleteEvalDataApi(id: string) {
  return request({
    url: `/toksim/resource/eval_model/delete/${id}`,
    method: "post"
  })
}

/** 改 */
export function updateEvalDataApi(data: FormData) {
  return request({
    headers: {
      "Content-Type": "multipart/form-data"
    },
    url: "/toksim/resource/eval_model/edit",
    method: "post",
    data
  })
}

/** 查 */
export function getEvalDataApi(params: Eval.PageTableRequestData) {
  return request<Eval.SearchEvalTableResponseData>({
    url: "/toksim/resource/eval_model/search",
    method: "post",
    data: params
  })
}

/** 查 */
export function getEvalListApi(eval_model_type: AlgoTypeEnum) {
  return request<Eval.EvalListResponseData>({
    url: `/toksim/resource/eval_model/${eval_model_type}/list`,
    method: "get"
  })
}

/** 根据id查询场景库信息 */
export function getEvalInfoApi(id: string) {
  return request<Eval.EvalInfoResponseData>({
    url: `/toksim/resource/eval_model/get/${id}`,
    method: "get"
  })
}
/** 获取仿真场景类型 */
export function getEvalTypeOptionsApi() {
  return request<ApiResponseData<string[]>>({
    url: `/toksim/resource/eval_model/type/get`,
    method: "get"
  })
}

/** 下载仿真场景场景 */
export function downloadEvalApi(id: string) {
  return request<AxiosResponse>({
    headers: {
      "Content-Type": "application/octet-stream"
    },
    responseType: "blob",
    url: `/toksim/resource/eval_model/download/${id}`,
    method: "get"
  })
}
